package com.sxhuayuan.parking.plugin.parking.bluecard.result;

import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializerFeature;

public class BluecardResult {
    public final static String SUCCESS = "success";
    public final static String FAIL = "fail";
    private String status;
    private String errorCode;
    private Object datas;
    
    public BluecardResult() {}
    public BluecardResult(String status, String errorCode) {
        super();
        this.status = status;
        this.errorCode = errorCode;
    }
    public BluecardResult(String status, String errorCode, Object datas) {
        this.status = status;
        this.datas = datas;
    }
    
    public static BluecardResult success(Object data) {
        return new BluecardResult(SUCCESS, null, data);
    }
    
    public static String  successJson(Object data ) {
        return JSONObject.toJSONString(BluecardResult.success(data));
    }
    
    public static String  successJsonWriteNull(Object data) {
        return JSONObject.toJSONString(BluecardResult.success(data), SerializerFeature.WriteMapNullValue, SerializerFeature.WriteNullStringAsEmpty);
    }
    
    public static BluecardResult fail(String errorCode) {
        return new BluecardResult(FAIL, errorCode);
    }
    public static String failJson(String errorCode) {
        return JSONObject.toJSONString(BluecardResult.fail(errorCode));
    }
    
    
    public String getStatus() {
        return status;
    }
    public void setStatus(String status) {
        this.status = status;
    }
    public String getErrorCode() {
        return errorCode;
    }
    public void setErrorCode(String errorCode) {
        this.errorCode = errorCode;
    }
    public Object getDatas() {
        return datas;
    }
    public void setDatas(Object datas) {
        this.datas = datas;
    }
    
    
}
